package twentyOne;

import java.io.IOException;

/**
 * 使用线程创建有响应的用户界面
 *
 * @author MSI PC
 * @since 2020-04-29 08:08
 */
public class ResponsiveUI extends Thread{
    private static volatile double d = 1;

    public ResponsiveUI() {
        setDaemon(true);
        start();
    }

    @Override
    public void run() {
        while (d > 0){
            d = d + (Math.PI + Math.E) / d;
        }
    }

    public static void main(String[] args) throws IOException {
        new ResponsiveUI();
        System.in.read();
        System.out.println("d = " + d);
    }
}


class UnResponsiveUI{
    private volatile double d = 1;

    public UnResponsiveUI() throws IOException {
        while (d > 0){
            d = d + (Math.PI + Math.E) / d;
        }
        System.in.read();
    }
}